﻿/* Copyright(C) 2006-2008 Dave Sexton  *
 * http://www.codeplex.com/aip         *
 * http://www.codeplex.com/aip/license *
 ***************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace DaveSexton.Web.Controls
{
	/// <summary>
	/// Specifies a localized description for a property or event.
	/// </summary>
	/// <seealso cref="Resources.PropertyAttributes"/>
	internal sealed class PropertyDescriptionAttribute : DescriptionAttribute
	{
		#region Public Properties
		/// <summary>
		/// Gets the description stored in this attribute.
		/// </summary>
		public override string Description
		{
			get
			{
				if (!replaced)
				{
					replaced = true;

					DescriptionValue = Resources.PropertyAttributes.ResourceManager.GetString(
						base.Description, System.Globalization.CultureInfo.CurrentCulture);
				}

				return base.Description;
			}
		}

		/// <summary>
		/// Gets a unique identifier for the attribute.
		/// </summary>
		public override object TypeId
		{
			get
			{
				return typeof(DescriptionAttribute);
			}
		}
		#endregion

		#region Private / Protected
		private bool replaced;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="PropertyDescriptionAttribute" /> class with the specified <paramref name="description"/>.
		/// </summary>
		/// <param name="description">The description text.</param>
		public PropertyDescriptionAttribute(string description)
			: base(description)
		{
		}
		#endregion
	}
}
